from django.db import models

# Create your models here.
class ListClass(models.Model):
    """
    首页列表
    """
    list_name = models.CharField(max_length=20, verbose_name='类名', help_text='类别名称')
    list_self = models.ForeignKey('ListClass', on_delete=models.CASCADE, verbose_name='上级大类', blank=True, null=True)
    tag = models.CharField(max_length=20, verbose_name='标志位', help_text='前断查询所用', default=0)
    show = models.BooleanField(default=True, verbose_name='是否展示')
    flag = models.IntegerField(verbose_name='排序位',  blank=True, null=True)


    def __str__(self):
        return str(self.list_name)

    class Meta:
        ordering = ('pk',)
        verbose_name = '首页展示列表'
        verbose_name_plural = verbose_name


class HomeFunction(models.Model):
    """
    首页功能
    """
    home_name = models.CharField(max_length=20, verbose_name='功能名', help_text='功能名称')
    tag = models.CharField(max_length=20, verbose_name='标志位', help_text='前断查询所用', default=0)
    show = models.BooleanField(default=True, verbose_name='是否展示')


    def __str__(self):
        return str(self.home_name)

    class Meta:
        ordering = ('pk',)
        verbose_name = '首页板块'
        verbose_name_plural = verbose_name


class HomeDetail(models.Model):
    """
    首页功能详情
    """
    fun_detail = models.ForeignKey(to=HomeFunction, on_delete=models.CASCADE, verbose_name='功能详情', related_name='hdetail')
    list_name = models.CharField(max_length=20, verbose_name='名称', help_text='详情名称')
    image = models.FileField(upload_to='image', max_length=200, verbose_name='详情图片', default="pic/123.jpg",blank=True,null='pic/123.jpg')
    tag = models.CharField(max_length=20, verbose_name='标志位', help_text='前断查询所用', default=0)
    show = models.BooleanField(default=True, verbose_name='是否展示')
    flag = models.IntegerField(verbose_name='排序位',  blank=True, null=True)
    introduction = models.TextField(verbose_name='简介', null=True, blank=True)


    def __str__(self):
        return str(self.list_name)

    class Meta:
        ordering = ('pk',)
        verbose_name = '首页展示列表'
        verbose_name_plural = verbose_name



class CanData(models.Model):
    """
    数据
    """
    name = models.CharField(max_length=20, verbose_name='名称',)
    flyl = models.CharField(max_length=20, verbose_name='浮动盈利',)
    zqy = models.CharField(max_length=20, verbose_name='总权益',)
    ccsz = models.CharField(max_length=20, verbose_name='权利仓市值',)
    djzj = models.CharField(max_length=20, verbose_name='冻结资金',)
    kyzj = models.CharField(max_length=20, verbose_name='可用资金',)
    ywcsz = models.CharField(max_length=20, verbose_name='义务仓市值',)
    type = models.CharField(max_length=20, verbose_name='标志',)


    def __str__(self):
        return str(self.id)

    class Meta:
        ordering = ('pk',)
        verbose_name = '具体数据'
        verbose_name_plural = verbose_name


class CanDataDetail(models.Model):
    """
    持仓
    """
    fun_detail = models.ForeignKey(to=CanData, on_delete=models.CASCADE, verbose_name='数据', related_name='hdetail')
    hymc = models.CharField(max_length=20, verbose_name='合约名称',)
    ccky = models.CharField(max_length=20, verbose_name='持仓/可用', help_text='/ 分割显示')
    xjjj = models.CharField(max_length=20, verbose_name='均价/现价', help_text='/ 分割显示')
    yk = models.CharField(max_length=20, verbose_name='盈亏')


    def __str__(self):
        return str(self.fun_detail)

    class Meta:
        ordering = ('pk',)
        verbose_name = '持仓'
        verbose_name_plural = verbose_name


